import { omit } from 'lodash-es'
import { StudentSchool } from '@/views/student/schema'
import modifySchema from '@/utils/modifySchema'

export default {
  type: 'object',
  properties: {
    layout: {
      'type': 'void',
      'x-component': 'FormLayout',
      'x-component-props': {
        labelWidth: 100,
      },
      'properties': {
        gird: {
          'type': 'void',
          'x-component': 'FormGrid',
          'x-component-props': {
            minColumns: 2,
            maxColumns: 2,
          },
          'properties': {
            ...modifySchema(omit(StudentSchool(), ['studentCode']), {
              studentGrade: {
                'x-component-props': {
                  clearable: true,
                  filterable: true,
                },
                'x-reactions': {
                  dependencies: ['.studentCollege#dataSource', '.studentCollege'],
                  fulfill: {
                    run: 'querySchoolDictByPre($self, $deps[0], $deps[1])',
                  },
                },
              },
              studentMajor: {
                'x-component-props': {
                  clearable: true,
                  filterable: true,
                },
                'x-reactions': {
                  dependencies: ['.studentGrade#dataSource', '.studentGrade'],
                  fulfill: {
                    run: 'querySchoolDictByPre($self, $deps[0], $deps[1])',
                  },
                },
              },
              studentClass: {
                'x-component-props': {
                  clearable: true,
                  filterable: true,
                },
                'x-reactions': {
                  dependencies: ['.studentMajor#dataSource', '.studentMajor'],
                  fulfill: {
                    run: 'querySchoolDictByPre($self, $deps[0], $deps[1])',
                  },
                },
              },
            }),
            province: {
              'type': 'string',
              'title': '省份',
              'x-component': 'Select',
              'x-decorator': 'FormItem',
              'x-component-props': {
                clearable: true,
                filterable: true,
              },
            },
          },
        },
      },
    },
  },
}
